package com.yyjj.yyjj.home.controller;


import com.yyjj.yyjj.common.auth.AuthContextHolder;
import com.yyjj.yyjj.common.result.Result;
import com.yyjj.yyjj.home.service.ItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "商品详情")
@RestController
@RequestMapping("api/home")
@RequiredArgsConstructor
public class ItemApiController {

    private final ItemService itemService;

    @ApiOperation(value = "获取sku详细信息")
    @GetMapping("item/{id}")
    public Result index(@PathVariable("id") Long id){
        Long userId = AuthContextHolder.getUserId();
        Map<String,Object> map= itemService.item(id,userId);
        return Result.ok(map);
    }



}
